﻿package{
	
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.display.MovieClip;
	
	import flash.events.MouseEvent;
	
	public class Menu_Help extends Sprite{
		
		var pageIndex:int;
		
		public function Menu_Help(){
			
			
			
			addEventListener(Event.ADDED_TO_STAGE, Init);
			
		}
		
		private function Init(e:Event) {
			removeEventListener(Event.ADDED_TO_STAGE, Init);
			
			pageIndex = 0;
			
			
			Close.addEventListener(MouseEvent.CLICK, onClickClose);
			
			Prev.gotoAndStop("Disable");
			Next.addEventListener(MouseEvent.CLICK, onClickNext);
			
		}
		
		
		private function onClickClose(e:MouseEvent) {
			trace(this, ": onClickClose");
			dispatchEvent(new NavigationEvent(NavigationEvent.CLOSE, "help", this));
			
		}
		
		private function onClickPrev(e:MouseEvent):void {
			if (Next.currentFrame == 33) {
				Next.addEventListener(MouseEvent.CLICK, onClickNext);
				Next.gotoAndStop("Normal");
			}
			
			pageIndex--;
			
			if(pageIndex <= 0){
				pageIndex = 0;
				Prev.gotoAndStop("Disable");
				if (Prev.hasEventListener(MouseEvent.CLICK)) 
				Prev.removeEventListener(MouseEvent.CLICK, onClickPrev);
			}
			
			screen.gotoAndStop((pageIndex+1) * 15);
		}
		
		private function onClickNext(e:MouseEvent):void {
			
			if (Prev.currentFrame == 33) {
				Prev.addEventListener(MouseEvent.CLICK, onClickPrev);
				Prev.gotoAndStop("Normal");
			}
			
			
			pageIndex++;
			
			if(pageIndex >= 5){
				pageIndex = 5;
				Next.gotoAndStop("Disable");
				if (Next.hasEventListener(MouseEvent.CLICK)) 
				Next.removeEventListener(MouseEvent.CLICK, onClickNext);
			}
			
			screen.gotoAndPlay(pageIndex * 15 + 1);
		}
		
	}
	
	
}